import random
from typing import List

class Card:
    """扑克牌类"""
    SUITS = ['♠', '♥', '♦', '♣']
    RANKS = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']
    
    def __init__(self, suit: str, rank: str):
        if suit not in self.SUITS:
            raise ValueError(f"Invalid suit: {suit}")
        if rank not in self.RANKS:
            raise ValueError(f"Invalid rank: {rank}")
        self.suit = suit
        self.rank = rank
        self._rank_value = self.RANKS.index(rank)  # 计算并存储点数值
        
    def __str__(self):
        return f"{self.suit}{self.rank}"
    
    def __repr__(self):
        return self.__str__()
    
    @property
    def rank_value(self) -> int:
        """获取点数值(2-14, 2最小,A最大)"""
        return self._rank_value

class Deck:
    """扑克牌组类"""
    def __init__(self):
        self.cards = [Card(suit, rank) 
                     for suit in Card.SUITS 
                     for rank in Card.RANKS]
        self.shuffle()
    
    def shuffle(self):
        """洗牌"""
        random.shuffle(self.cards)
    
    def deal(self, n: int = 1) -> List[Card]:
        """发牌
        
        Args:
            n: 要发的牌数
            
        Returns:
            发出的牌列表
        """
        if n > len(self.cards):
            raise ValueError("牌组中没有足够的牌")
        return [self.cards.pop() for _ in range(n)] 